package net.zjitc.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableWebMvc
@Configuration
@ComponentScan("net.zjitc.controller")
public class SpringMvcConfig implements WebMvcConfigurer {
    //配置Spring MVC的默认Servlet处理
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer){
        configurer.enable();
        //configurer.enable() 启用默认Servlet处理，使得静态资源（如HTML、CSS、JavaScript文件）能够被正确处理。configurer.enable() 启用默认Servlet处理，使得静态资源（如HTML、CSS、JavaScript文件）能够被正确处理。
    }
    //配置视图解析器
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry){
        registry.jsp().prefix("/").suffix(".jsp");
    }
}
